﻿using BCEntity.TMS.VehicleCategoryReference;
using BCEntity.TMS.VehicleType;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace BCData.TMS.VehicleType
{
    /// <summary>
    /// 车辆类型数据库访问
    /// </summary>
    public interface IVehicleTypeData
    {
        /// <summary>
        /// 检查车型是否存在
        /// </summary>
        /// <param name="vehicleTypeId">车型Id</param>
        /// <returns></returns>
        Task<object> CheckVehicleTypeExists(int vehicleTypeId);

        /// <summary>
        /// 检查车型是否存在
        /// </summary>
        /// <param name="vehicleTypeId"></param>
        /// <returns></returns>
        Task<bool> CheckVehicleTypeExistsAsync(int vehicleTypeId);

        /// <summary>
        /// 新增
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        Task<VehicleTypeEntity> InserAsync(VehicleTypeEntity entity, List<VehicleCategoryReferenceEntity> entities = null);

        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        Task<VehicleTypeEntity> UpdateAsync(VehicleTypeEntity entity, List<VehicleCategoryReferenceEntity> entities = null);

        /// <summary>
        /// 修改车型状态
        /// </summary>
        /// <param name="vehicleTypeId">车辆类型id</param>
        /// <param name="isEnabled">是否启用</param>
        /// <returns></returns>
        Task<int> UpdateAsync(int vehicleTypeId, bool isEnabled);

        /// <summary>
        /// 删除车型
        /// </summary>
        /// <param name="vehicleTypeId">车辆类型id</param>
        /// <returns></returns>
        Task<int> DeleteAsync(int vehicleTypeId);

        /// <summary>
        /// 通过id查询车辆数据
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        Task<VehicleTypeExpandEntity> GetByIdAsync(int id);

        /// <summary>
        /// 车辆类型列表
        /// </summary>
        /// <returns></returns>
        Task<IEnumerable<VehicleTypeEntity>> GetAsync(string vehicleTypeName, string vehicleTypeEnum);
        /// <summary>
        /// 获取车辆
        /// </summary>
        /// <param name="vehicleEndWeight">车辆最大载重</param>
        /// <param name="vehicleEndStere">车辆最大立方</param>
        /// <returns></returns>
        Task<VehicleTypeEntity> GetVehicle(int vehicleEndWeight, decimal vehicleEndStere);

        /// <summary>
        /// 列表分页条件查询
        /// </summary>
        /// <param name="categoryReferenceIdStr">车辆分类对应Id</param>
        /// <param name="vehicleTypeId">车辆类型Id</param>
        /// <param name="vehicleTypeEnum">车辆所属类型（对应字典引用检索键）</param>
        /// <param name="maxStartWeight">最大开始载重</param>
        /// <param name="maxEndWeight">最大结束载重</param>
        /// <param name="maxStartStere">车辆最大起始载货立方</param>
        /// <param name="maxEndStere">车辆最大结束载货立方</param>
        /// <param name="enabled">是否启用</param>
        /// <param name="pageIndex">当前页码</param>
        /// <param name="pageSize">页面大小</param>
        /// <returns></returns>
        Task<(IEnumerable<VehicleTypeExpandEntity>, int)> GetAsync(string categoryReferenceIdStr, int? vehicleTypeId, string vehicleTypeEnum, int? maxStartWeight, int? maxEndWeight, decimal? maxStartStere, decimal? maxEndStere, bool? enabled, int pageIndex, int pageSize);

        /// <summary>
        /// 获取车辆类型列表
        /// </summary>
        /// <returns></returns>
        Task<IEnumerable<VehicleTypeExpandEntity>> GetVehicleTypes();

        /// <summary>
        /// 获取车型图片
        /// </summary>
        /// <param name="searchKey">车辆所属类型检索键</param>
        /// <returns></returns>
        Task<string> GetVehicleTypeImg(string searchKey);

        /// <summary>
        /// 获取最大的车辆类型值
        /// </summary>
        /// <returns></returns>
        Task<MaxVehicleTypeValueEntity> MaxVehicleTypeValue();

        /// <summary>
        /// 根据车型名称查询车型数据
        /// </summary>
        /// <param name="vehicleTypeName">车型名称</param>
        /// <returns></returns>
        Task<VehicleTypeEntity> GetByVehicleTypeName(string vehicleTypeName);

        /// <summary>
        /// 获取车型数据
        /// </summary>
        /// <returns></returns>
        Task<IEnumerable<VehicleTypeEntity>> GetList();
        
        /// <summary>
        /// 获取启用的车型列表
        /// </summary>
        /// <param name="agentRecordId">代理商ID</param>
        /// <returns></returns>
        Task<IEnumerable<VehicleTypeExpandEntity>> GetListByAgentRecordId(long? agentRecordId);
    }
}